package com.haofengsoft.scce.db.biz.consultation;

import java.util.List;

import android.content.Context;

import com.haofengsoft.scce.ManageApplication;
import com.haofengsoft.scce.db.DaoSession;
import com.haofengsoft.scce.db.dao.consultation.NanJingDao;
import com.haofengsoft.scce.db.entity.consultation.NanJing;

import de.greenrobot.dao.query.QueryBuilder;

/**
 * Created by admin on 2015/7/23.
 */
public class NanJingBiz {
    private static NanJingBiz instance;
    private static Context appContext;
    private NanJingDao dao;

    private NanJingBiz() {
    }

    public static NanJingBiz getInstance(Context context) {
        if (instance == null) {
            instance = new NanJingBiz();
            if (appContext == null) {
                appContext = context.getApplicationContext();
            }
            DaoSession daoSession = ManageApplication.getDaoSession(context);
            instance.dao = daoSession.getNanJingDao();
        }
        return instance;
    }

    public void insertNanjingList(final List<NanJing> infoList) {
        dao.insertOrReplaceInTx(infoList);
    }

    public List<NanJing> gainNanjingList() {
        QueryBuilder qb = dao.queryBuilder();
        return qb.list();
    }

    public void deleteAll() {
        dao.deleteAll();
    }
}
